package com.lboyang;

import com.lboyang.api.HelloService;

import com.lboyang.core.annotation.NnziScan;
import com.lboyang.provider.config.RpcServiceConfig;
import com.lboyang.remoting.transport.netty.server.NettyRpcServer;
import com.lboyang.serviceImpl.HelloServiceImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @Description
 * @Date 2021/9/12 17:23
 * @author: A.iguodala
 */
@NnziScan(basePackage = {"com.lboyang"})
public class Main {

    public static void main(String[] args) {
        // Register service via annotation
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(Main.class);
        NettyRpcServer nettyRpcServer = (NettyRpcServer) applicationContext.getBean("nettyRpcServer");
        // Register service manually
        HelloService helloService2 = new HelloServiceImpl();
        RpcServiceConfig rpcServiceConfig = RpcServiceConfig.builder()
                .group("test").version("1").service(helloService2).build();
        nettyRpcServer.registerService(rpcServiceConfig);
        nettyRpcServer.start();
    }
}
